// 
// Decompiled by Procyon v0.5.36
// 

package com.cyberfend.cyfsecurity;

import java.util.concurrent.atomic.*;
import android.util.*;
import android.os.*;
import com.cyberfend.cyfsecurity.b.*;
import android.widget.*;
import android.text.*;
import java.util.*;
import android.view.*;
import android.app.*;

final class h
{
    private com.cyberfend.cyfsecurity.x c;
    com.cyberfend.cyfsecurity.k a;
    com.cyberfend.cyfsecurity.p b;
    private com.cyberfend.cyfsecurity.ab d;
    private static final java.util.ArrayList<java.lang.Integer> e;
    private java.util.concurrent.atomic.AtomicBoolean f;
    private boolean g;
    
    h() {
        this.c = null;
        this.a = null;
        this.b = null;
        this.d = null;
        this.f = new java.util.concurrent.atomic.AtomicBoolean(false);
        this.g = false;
    }
    
    final synchronized java.lang.String a() {
        com.cyberfend.cyfsecurity.b.a.a("Manager", "Getting sensor data", new java.lang.Throwable[0]);
        java.lang.String a = "default-mobile";
        try {
            if (this.a == null || this.b == null) {
                com.cyberfend.cyfsecurity.b.a.c("Manager", "AkamaiBMP SDK is not initialized", new java.lang.Throwable[0]);
                return a;
            }
            if (android.os.Looper.myLooper() == android.os.Looper.getMainLooper()) {
                final android.util.Pair b;
                a = (java.lang.String)(b = this.b()).first;
                if (b.second) {
                    this.c();
                }
            }
            else {
                final android.os.Handler handler = new android.os.Handler(android.os.Looper.getMainLooper());
                final class a implements java.lang.Runnable
                {
                    public java.lang.String a;
                    
                    a() {
                        this.a = "default-mobile";
                    }
                    
                    @java.lang.Override
                    public final void run() {
                        try {
                            final android.util.Pair<java.lang.String, java.lang.Boolean> b = com.cyberfend.cyfsecurity.h.this.b();
                            this.a = (java.lang.String)b.first;
                            if (b.second) {
                                com.cyberfend.cyfsecurity.h.this.c();
                            }
                        }
                        catch (java.lang.Exception ex) {
                            com.cyberfend.cyfsecurity.b.a.c("Manager", "Failed to get sensor data", ex);
                            com.cyberfend.cyfsecurity.f.a(ex);
                        }
                        synchronized (this) {
                            this.notify();
                        }
                    }
                }
                final com.cyberfend.cyfsecurity.h.a a3;
                final com.cyberfend.cyfsecurity.h.a a2 = a3 = new com.cyberfend.cyfsecurity.h.a();
                synchronized (a2) {
                    handler.post((java.lang.Runnable)a3);
                    a3.wait();
                }
                a = a3.a;
            }
        }
        catch (java.lang.Exception ex) {
            com.cyberfend.cyfsecurity.b.a.c("Manager", "Failed to get sensor data", ex);
            com.cyberfend.cyfsecurity.f.a(ex);
        }
        final java.lang.Throwable[] array = new java.lang.Throwable[0];
        return a;
    }
    
    final android.util.Pair<java.lang.String, java.lang.Boolean> b() throws java.lang.Exception {
        com.cyberfend.cyfsecurity.b.a.a("Manager", "Building sensor data", new java.lang.Throwable[0]);
        final long uptimeMillis = android.os.SystemClock.uptimeMillis();
        if (com.cyberfend.cyfsecurity.e.o.equals("default_performance")) {
            com.cyberfend.cyfsecurity.e.o = com.cyberfend.cyfsecurity.q.a();
        }
        final java.lang.String l = com.cyberfend.cyfsecurity.e.l;
        final java.lang.String string = l + "," + com.cyberfend.cyfsecurity.u.a(l) + "," + java.lang.String.valueOf(new java.util.Random().nextInt()) + "," + java.lang.String.valueOf(com.cyberfend.cyfsecurity.d.a / 2L);
        final com.cyberfend.cyfsecurity.b.b<java.lang.String, java.lang.Long, java.lang.Long> d = this.b.d();
        final com.cyberfend.cyfsecurity.b.b<java.lang.String, java.lang.Long, java.lang.Long> d2 = this.a.d();
        if (d.c < 10L && d2.c < 10L && com.cyberfend.cyfsecurity.ae.a().b()) {
            final java.lang.String b = com.cyberfend.cyfsecurity.ae.a().b;
            if (this.f.compareAndSet(false, true)) {
                new java.util.Timer().schedule(new java.util.TimerTask() {
                    @java.lang.Override
                    public final void run() {
                        com.cyberfend.cyfsecurity.h.this.a();
                        f.compareAndSet(true, false);
                    }
                }, 3500L);
            }
            return (android.util.Pair<java.lang.String, java.lang.Boolean>)new android.util.Pair((java.lang.Object)b, (java.lang.Object)java.lang.Boolean.FALSE);
        }
        this.b.c();
        this.a.c();
        final java.lang.String c = com.cyberfend.cyfsecurity.e.c;
        final java.lang.String a = com.cyberfend.cyfsecurity.e.a;
        final java.lang.String k = com.cyberfend.cyfsecurity.e.k;
        final java.lang.String n = com.cyberfend.cyfsecurity.e.n;
        java.lang.String s = "do_en";
        if (this.b.a.a) {
            s = "do_unr";
        }
        else if (!this.b.b) {
            s = "do_dis";
        }
        java.lang.String s2 = "dm_en";
        if (this.a.a.a) {
            s2 = "dm_unr";
        }
        else if (!this.a.b) {
            s2 = "dm_dis";
        }
        final java.lang.String string2 = s + "," + s2 + "," + "t_en";
        final long n2 = (android.os.SystemClock.uptimeMillis() - uptimeMillis) * 1000L;
        final long n3 = com.cyberfend.cyfsecurity.e.d + com.cyberfend.cyfsecurity.e.b + d.b + d2.b;
        final long n4 = java.lang.System.currentTimeMillis() - com.cyberfend.cyfsecurity.d.a;
        final java.lang.String string3 = com.cyberfend.cyfsecurity.e.d + "," + com.cyberfend.cyfsecurity.e.b + "," + (long)d.b + "," + (long)d2.b + "," + n3 + "," + n4 + "," + com.cyberfend.cyfsecurity.e.i + "," + com.cyberfend.cyfsecurity.e.j + "," + (long)d.c + "," + (long)d2.c + "," + com.cyberfend.cyfsecurity.d.p * 1000L + "," + n2 + "," + com.cyberfend.cyfsecurity.d.q + "," + a((int)n3, (int)(com.cyberfend.cyfsecurity.e.i + com.cyberfend.cyfsecurity.e.j + d.c + d2.c), (int)n4) + "," + com.cyberfend.cyfsecurity.d.a + ",0";
        final java.lang.String string4 = "2.1.3-1,2,-94,-100," + string + "-1,2,-94,-101," + string2 + "-1,2,-94,-105,-1,2,-94,-102," + k + "-1,2,-94,-108," + c + "-1,2,-94,-110,-1,2,-94,-117," + a + "-1,2,-94,-111," + d.a + "-1,2,-94,-109," + d2.a + "-1,2,-94,-112,-1,2,-94,-115," + string3 + "-1,2,-94,-106," + com.cyberfend.cyfsecurity.d.f + "," + com.cyberfend.cyfsecurity.d.g + "-1,2,-94,-70,-1,2,-94,-80,-1,2,-94,-120," + com.cyberfend.cyfsecurity.e.m + "-1,2,-94,-112," + com.cyberfend.cyfsecurity.e.o + "-1,2,-94,-121,-1,2,-94,-103," + n;
        new java.lang.StringBuilder("Sensor Data, Key Event size: ").append(c.length());
        final java.lang.Throwable[] array = new java.lang.Throwable[0];
        new java.lang.StringBuilder("Sensor Data, Touch Event size: ").append(a.length());
        final java.lang.Throwable[] array2 = new java.lang.Throwable[0];
        new java.lang.StringBuilder("Sensor Data, Orientation Event size: ").append(d.a.length());
        final java.lang.Throwable[] array3 = new java.lang.Throwable[0];
        new java.lang.StringBuilder("Sensor Data, Motion Event size: ").append(d2.a.length());
        final java.lang.Throwable[] array4 = new java.lang.Throwable[0];
        new java.lang.StringBuilder("Sensor Data, Misc Stat size: ").append(string3.length());
        final java.lang.Throwable[] array5 = new java.lang.Throwable[0];
        new java.lang.StringBuilder("Plain Sensor Data, Total size: ").append(string4.length());
        final java.lang.Throwable[] array6 = new java.lang.Throwable[0];
        final java.lang.Throwable[] array7 = new java.lang.Throwable[0];
        com.cyberfend.cyfsecurity.b.a.a("Manager", "Plain-BuildSensorData-Time: " + (android.os.SystemClock.uptimeMillis() - uptimeMillis) + "ms", new java.lang.Throwable[0]);
        final java.lang.String a2 = com.cyberfend.cyfsecurity.ad.a().a(string4);
        new java.lang.StringBuilder("Encrypted Sensor Data, Total size: ").append(a2.length());
        final java.lang.Throwable[] array8 = new java.lang.Throwable[0];
        final java.lang.Throwable[] array9 = new java.lang.Throwable[0];
        if (d.c >= 10L || d2.c >= 10L) {
            com.cyberfend.cyfsecurity.ae.a().a(a2);
        }
        return (android.util.Pair<java.lang.String, java.lang.Boolean>)new android.util.Pair((java.lang.Object)a2, (java.lang.Object)java.lang.Boolean.TRUE);
    }
    
    final void c() {
        try {
            final java.lang.Throwable[] array = new java.lang.Throwable[0];
            com.cyberfend.cyfsecurity.e.a();
            com.cyberfend.cyfsecurity.d.a();
            if (com.cyberfend.cyfsecurity.CYFMonitor.isActivityVisible()) {
                this.g();
                this.e();
                this.f();
                this.d();
            }
        }
        catch (java.lang.Exception ex) {
            new java.lang.StringBuilder("Exception occurred:").append(ex.getMessage());
            final java.lang.Throwable[] array2 = new java.lang.Throwable[0];
            com.cyberfend.cyfsecurity.f.a(ex);
        }
    }
    
    static synchronized boolean a(final android.view.Window window) throws java.lang.Exception {
        final int hashCode = window.hashCode();
        for (int i = 0; i < com.cyberfend.cyfsecurity.h.e.size(); ++i) {
            if (hashCode == com.cyberfend.cyfsecurity.h.e.get(i)) {
                return true;
            }
        }
        com.cyberfend.cyfsecurity.h.e.add(hashCode);
        return false;
    }
    
    public final void a(final android.view.ViewGroup viewGroup) {
        try {
            final java.util.ArrayList<android.view.View> a = com.cyberfend.cyfsecurity.s.a((android.view.View)viewGroup);
            for (int i = 0; i < a.size(); ++i) {
                final android.view.View view;
                if ((view = a.get(i)) instanceof android.widget.EditText) {
                    if (!this.g) {
                        this.c = new com.cyberfend.cyfsecurity.x();
                        this.g = true;
                    }
                    new java.lang.StringBuilder("listener adding for edittext ").append(view.toString());
                    final java.lang.Throwable[] array = new java.lang.Throwable[0];
                    final com.cyberfend.cyfsecurity.x c = this.c;
                    final android.widget.EditText editText = (android.widget.EditText)view;
                    final com.cyberfend.cyfsecurity.x x = c;
                    com.cyberfend.cyfsecurity.b.a.a("TextChangeManager", "Listening on edit text: " + editText.getId(), new java.lang.Throwable[0]);
                    final int a2 = com.cyberfend.cyfsecurity.u.a(java.lang.String.valueOf(editText.getId()));
                    if (!com.cyberfend.cyfsecurity.e.k.toLowerCase().contains(java.lang.Integer.toString(a2).toLowerCase())) {
                        com.cyberfend.cyfsecurity.e.k = com.cyberfend.cyfsecurity.e.k + a2 + ";";
                    }
                    if ((editText.getInputType() & 0x81) == 0x81 || (editText.getInputType() & 0x12) == 0x12 || (editText.getInputType() & 0x91) == 0x91 || (editText.getInputType() & 0xE1) == 0xE1) {
                        final com.cyberfend.cyfsecurity.w w = new com.cyberfend.cyfsecurity.w(a2, true);
                        editText.addTextChangedListener((android.text.TextWatcher)w);
                        w.addObserver(x.a);
                    }
                    else {
                        final com.cyberfend.cyfsecurity.w w2 = new com.cyberfend.cyfsecurity.w(a2, false);
                        editText.addTextChangedListener((android.text.TextWatcher)w2);
                        w2.addObserver(x.a);
                    }
                }
            }
        }
        catch (java.lang.Exception ex) {
            com.cyberfend.cyfsecurity.b.a.c("Manager", "Exception in creating text listener", ex);
            com.cyberfend.cyfsecurity.f.a(ex);
        }
    }
    
    public final void b(final android.view.Window window) {
        try {
            if (this.d == null) {
                this.d = new com.cyberfend.cyfsecurity.ab();
            }
            final com.cyberfend.cyfsecurity.ab d = this.d;
            com.cyberfend.cyfsecurity.b.a.a("TouchManager", "Listening on window", new java.lang.Throwable[0]);
            d.a = android.os.SystemClock.uptimeMillis();
            final com.cyberfend.cyfsecurity.aa callback = new com.cyberfend.cyfsecurity.aa(window.getCallback());
            window.setCallback((android.view.Window$Callback)callback);
            callback.addObserver(d);
        }
        catch (java.lang.Exception ex) {
            com.cyberfend.cyfsecurity.b.a.c("Manager", "Exception in creating touch manager", ex);
            com.cyberfend.cyfsecurity.f.a(ex);
        }
    }
    
    public final synchronized void a(final android.app.Application application) {
        try {
            if (this.b != null) {
                return;
            }
            this.b = new com.cyberfend.cyfsecurity.p();
            final com.cyberfend.cyfsecurity.p b = this.b;
            com.cyberfend.cyfsecurity.b.a.a("OrientationManager", "Initializing orientation manager", new java.lang.Throwable[0]);
            final com.cyberfend.cyfsecurity.p p = b;
            final long uptimeMillis = android.os.SystemClock.uptimeMillis();
            p.e = uptimeMillis;
            p.d = uptimeMillis;
            b.a = new com.cyberfend.cyfsecurity.o(application);
        }
        catch (java.lang.Exception ex) {
            com.cyberfend.cyfsecurity.b.a.c("Manager", "Exception in creating orientation manager", ex);
            com.cyberfend.cyfsecurity.f.a(ex);
        }
    }
    
    public final void d() {
        try {
            this.b.a();
        }
        catch (java.lang.Exception ex) {
            com.cyberfend.cyfsecurity.b.a.c("Manager", "Exception in starting orientation manager", ex);
            com.cyberfend.cyfsecurity.f.a(ex);
        }
    }
    
    public final void e() {
        try {
            this.b.b();
        }
        catch (java.lang.Exception ex) {
            com.cyberfend.cyfsecurity.b.a.c("Manager", "Exception in stopping orientation manager", ex);
            com.cyberfend.cyfsecurity.f.a(ex);
        }
    }
    
    public final synchronized void b(final android.app.Application application) {
        try {
            if (this.a != null) {
                return;
            }
            this.a = new com.cyberfend.cyfsecurity.k();
            final com.cyberfend.cyfsecurity.k a = this.a;
            com.cyberfend.cyfsecurity.b.a.a("MotionManager", "Initializing motion manager", new java.lang.Throwable[0]);
            final com.cyberfend.cyfsecurity.k k = a;
            final long uptimeMillis = android.os.SystemClock.uptimeMillis();
            k.e = uptimeMillis;
            k.d = uptimeMillis;
            a.a = new com.cyberfend.cyfsecurity.j(application);
        }
        catch (java.lang.Exception ex) {
            com.cyberfend.cyfsecurity.b.a.c("Manager", "Exception in creating motion manager", ex);
            com.cyberfend.cyfsecurity.f.a(ex);
        }
    }
    
    public final void f() {
        try {
            this.a.a();
        }
        catch (java.lang.Exception ex) {
            com.cyberfend.cyfsecurity.b.a.c("Manager", "Exception in starting motion manager", ex);
            com.cyberfend.cyfsecurity.f.a(ex);
        }
    }
    
    public final void g() {
        try {
            this.a.b();
        }
        catch (java.lang.Exception ex) {
            com.cyberfend.cyfsecurity.b.a.c("Manager", "Exception in stopping motion manager", ex);
            com.cyberfend.cyfsecurity.f.a(ex);
        }
    }
    
    private static long a(final int n, final int n2, final int n3) {
        return com.cyberfend.cyfsecurity.a.a.a((long)n << 32 | ((long)n2 & 0xFFFFFFFFL), n3);
    }
    
    static {
        e = new java.util.ArrayList<java.lang.Integer>();
    }
}
